﻿using AutoMapper;
using Smalt.DomainModels.Models;
using Smalt.MVC.Mappings.Resolvers;
using Smalt.MVC.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Smalt.MVC.Mappings
{
    public class DomainToViewModelProfile : Profile
    {
        public override string ProfileName
        {
            get
            {
                return "ViewModelToDomain";
            }
        }

        protected override void Configure()
        {
            Mapper.CreateMap<Community, CommunityViewModel>()
                .ForMember(
                    dest => dest.CreatorName,
                    opt => opt.MapFrom(src => src.Creator.UserName))
                .ForMember(
                    dest => dest.Teams,
                    opt => opt.ResolveUsing<TeamViewResolver>());
                
        }
    }
}